package main

import (
    "bufio"
    "fmt"
    "os"

    "llama-chatbot-go/llm"
)

func main() {
    model, err := llm.Load("models/gemma-2b.gguf")
    if err != nil {
        panic(err)
    }
    defer model.Close()

    session := llm.NewSession("你是一個冷靜理性的開發顧問，擅長邏輯推理與問題排查。")

    reader := bufio.NewReader(os.Stdin)

    for {
        fmt.Print(">> ")
        input, _ := reader.ReadString('\n')

        prompt := session.BuildPrompt(input)
        fmt.Println("🤖 回應中...")

        response := ""
        for r := range model.Predict(prompt) {
            fmt.Print(r.Content)
            response += r.Content
        }

        fmt.Println()
        session.Append(input, response)
    }
}